package ro.toporjinschi.anytaxi;

import java.util.ArrayList;
import java.util.List;

import ro.toporjinschi.anytaxi.fragments.MapFragment;
import ro.toporjinschi.anytaxi.fragments.MyPlacesFragment;
import android.support.v4.app.Fragment;

public class TabManager {
    private List<TabDetails> tabs = new ArrayList<TabDetails>();

    public TabManager() {
        tabs.add(new TabDetails(R.string.mapTabLabel, R.drawable.ic_tab_pin, new MapFragment(), "tagMap"));
        tabs.add(new TabDetails(R.string.places, R.drawable.ic_tab_places, new MyPlacesFragment(), "tagMyPlaces"));
    }

    public TabDetails getTabByTag(String tag) {
        int i;
        for (i = 0; i < tabs.size(); i++) {
            if (tabs.get(i).getTag().equalsIgnoreCase(tag)) {
                break;
            }
        }
        return tabs.get(i);
    }

    public List<TabDetails> getTabs() {
        return tabs;
    }

    public Fragment getFragmentForTag(String tag) {
        return getTabByTag(tag).getFragment();
    }

    public Fragment getFragmentOfFirstTab() {
        return getDetilsOfFirstTab().getFragment();
    }

    public TabDetails getDetilsOfFirstTab() {
        return tabs.get(0);
    }
}
